diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-03 10:56:21 +0300 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-03 10:56:21 +0300 |
| commit | 456cf011b36de91c9936994b1fa45703adcd309b (patch) | |
| tree | 8e60daf998f731ac50d100fa490eaecae1168042 /src/pages/notes/[...slug].astro | |
Initial fork of chrismwilliams/astro-theme-cactus theme
Diffstat (limited to 'src/pages/notes/[...slug].astro')
| -rw-r--r-- | src/pages/notes/[...slug].astro | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/pages/notes/[...slug].astro b/src/pages/notes/[...slug].astro new file mode 100644 index 0000000..2ce847d --- /dev/null +++ b/src/pages/notes/[...slug].astro @@ -0,0 +1,31 @@ +--- +import { getCollection } from "astro:content"; + +import Note from "@/components/note/Note.astro"; +import PageLayout from "@/layouts/Base.astro"; +import type { GetStaticPaths, InferGetStaticPropsType } from "astro"; + +// if you're using an adaptor in SSR mode, getStaticPaths wont work -> https://docs.astro.build/en/guides/routing/#modifying-the-slug-example-for-ssr +export const getStaticPaths = (async () => { + const allNotes = await getCollection("note"); + return allNotes.map((note) => ({ + params: { slug: note.id }, + props: { note }, + })); +}) satisfies GetStaticPaths; + +export type Props = InferGetStaticPropsType<typeof getStaticPaths>; + +const { note } = Astro.props; + +const meta = { + description: + note.data.description || + `Read about my note posted on: ${note.data.publishDate.toLocaleDateString()}`, + title: note.data.title, +}; +--- + +<PageLayout meta={meta}> + <Note as="h1" note={note} /> +</PageLayout> |
